﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<Excell_On_Services.Models.OrderService>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Details
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<p class="mc_title">Managerment Orders</p>
    <div class="content-box"><!-- Start Content Box -->
        <div class="content-box-header"></div>

        <div class="content-box-content">
			   
		    <div class="tab-content default-tab" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
				
<% int i = 0; %>
    <table border="0" cellpadding="2" cellspacing= "2">
        <thead >
        <tr class="bg_none">
            <th>Order ID</th>
            <td><%: Model.OrderID%></td>
        </tr>
        <tr class="bg_none">
            <th> Client username</th>
            <td><%: Model.Client.aspnet_Users.UserName %></td>
        </tr>
        <tr class="bg_none">
            <th> Client Phone</th>
            <td><%: Model.Client.Phone %></td>
        </tr>
        <tr class="bg_none">
            <th> Client Email</th>
            <td><%: Membership.GetUser(Model.Client.aspnet_Users.UserName).Email %></td>
        </tr>
        <tr class="bg_none">
            <th> Client Address</th>
            <td><%: Model.Client.Address %></td>
        </tr>
        <tr class="bg_none">
            <th> Client Order</th>
            <td><%: Model.Client.CompanyName %></td>
        </tr>
        <tr class="bg_none">
            <th>Order Date</th>
            <td><%:Model.OrderDate%></td>
        </tr>
        <tr class="bg_none">
            <th>Status</th>
            <td>
                <% if ((bool)Model.Status)
                   {%>
                       <img src="../../Content/images/icons/tick.png" alt="Details" title="Approved" />
                   <%}
                   else
                   {%>
                        <b>Wait</b>
                 <%} %>
                       
                       
            </td>
            <td>
                <input type="button" class="button" value="Change status" onclick="location.href='<%: Url.Action("EditStatusOrder", "Order",new { id = Model.OrderID }) %>'" />
            </td>
        </tr>
        </thead>
     </table>

     <div class="infomation_order">
        <b>List Details Order Services:</b>
     </div>
     <table border="0" cellpadding="2" cellspacing= "2" width="100%">
        <thead>
            <tr>
                <th>S.No</th>
                <th>
                    OrderID
                </th>
                <th>
                    ServiceID
                </th>
                <th>
                    Price
                </th>
                <th>
                    Quantity
                </th>
                <th>
                    Date Start Service
                </th>
                <th>
                    Date End Service
                </th>
                <th>
                    Amout money
                </th>
            </tr>
        </thead>
        <% decimal totalMoney = 0; %>
        

    <% foreach (var item in Model.OrderDetails) { %>
    
        <tr>
            <td>
               <%-- <%: Html.ActionLink("Edit", "Edit", new { id=item.OrderID }) %> |
                <%: Html.ActionLink("Details", "Details", new { id=item.OrderID })%> |
                <%: Html.ActionLink("Delete", "Delete", new { id=item.OrderID })%>--%>
                <% i++; %>
            </td>
            <td>
                <%: item.OrderID %>
            </td>
            <td>
                <%: item.Service.Name %>
            </td>
            <td>
                <%: String.Format("{0:F}", item.Price) %>
            </td>
            <td style="text-align: right;">
                <%: item.Quantity %>
            </td>
            <td>
                <%: item.StartDate %>
            </td>
            <td>
                <%: item.EndDate %>
            </td>
            <td>
                <%: (item.Quantity * item.Price * (long)((TimeSpan)(item.EndDate - item.StartDate)).TotalDays).ToString("c")%>
            </td>
            <td style='display:none;'>
            <%: totalMoney += item.Quantity * item.Price * (long)((TimeSpan)(item.EndDate - item.StartDate)).TotalDays %>
            </td>
            
        </tr>
    
    <% } %>
    <tr >
        <td colspan ="8">
            <h4>
            Total money = <% = totalMoney.ToString("c") %>
            </h4>
        </td>
    </tr>
    </table>

    <div class="infomation_order">
        <b>List payment Date</b>
     </div>
     <% i = 1; %>
    <table border="0" cellpadding="2" cellspacing= "2" width="100%">
        <thead>
            <tr>
                <th>S.No</th>
                <th>
                    PayemntID
                </th>
                <th>
                    OrderID
                </th>
                <th>
                    Payment
                </th>
                <th>
                    Duration Date
                </th>
                <th>
                    Date paid
                </th>
            </tr>
          </thead>
          <%string durationType = ""; %>  
          <% foreach (var item in Model.OrderPayments)
             { 
             %>
             <%if (item.DurationDate < DateTime.Now && item.DatePaid == null)
               {
                   durationType = "trDuration";
               }
               else
               {
                   durationType = "";
               } %>
               
             <tr class = "<%=durationType %>">
                <td><%i++; %></td>
                 <td>
                    <%: item.PaymentID %>
                 </td>
                 <td>
                    <%:item.OrderID %>
                 </td>
                 <td>
                    <%:((decimal)item.Payment).ToString("c") %>
                 </td>
                 <td>
                    <%:item.DurationDate %>
                 </td>
                 <td>
                    <%:item.DatePaid%>
                 </td>
                 <td>
                    <%if (item.DatePaid == null)
                      { %>
                    <a class="button" href="<%: Url.Action("PaidPaymentOrder", new {id=item.PaymentID }) %>" title="Paid" >Paid </a>
                    <%} %>
                 </td>
             </tr>
          <% } %>
    </table>
</asp:Content>
